<div id="pbbIndex_div" style="width: 100%;height: 100%; ">
    <!--日期-->
    <div style="height: 6%;margin-left: 20px">
        <div class="layui-inline" style="background-color: #CCE6FF">
            <button onclick="loadPbbData()" class="layui-btn "><i class="fa fa-refresh fa-fw" aria-hidden="true"></i>加载/刷新员工</button>
        </div>
        <div class="layui-inline"style="padding: 10px" >
            <label class="layui-inline">选择月份</label>
            <div class="layui-input-inline">
                <input id="pbbIndex_div_date" placeholder="请选择年月" class="layui-input">
            </div>
        </div>
        <div class="layui-inline" style="background-color: #CCE6FF">
            <button onclick="loadPbbData2()" class="layui-btn layui-btn-normal"><i class="fa fa-bar-chart fa-fw" aria-hidden="true"></i>当月绩效数据</button>
        </div>
    </div>
    <div id="pbbIndexAccordion" >
    <!--检验员表格-->
    <div  title="<span class='opal-txt_bold opal-txt_size opal-txt_color_1'><i class='fa fa-align-justify fa-fw fa-spin'></i> 检验员</span>"  >
        <div id='pbbTableToolbarA'>
            <a class="easyui-linkbutton c1" data-options="plain:true" style="height: 90%" onclick="javaScript:$('#pbbIndex_yuangong_table').edatagrid('saveRow')"><i class="fa fa-floppy-o fa-fw" aria-hidden="true"></i>保存</a>
            <a class="easyui-linkbutton" data-options="plain:true">|</a>
            <a class="easyui-linkbutton c6" data-options="plain:true" style="height: 90%" onclick="javaScript:$('#pbbIndex_yuangong_table').edatagrid('addRow')"><i class="fa fa-plus-square fa-fw" aria-hidden="true"></i>新增</a>
            <a class="easyui-linkbutton" data-options="plain:true">|</a>
            <a class="easyui-linkbutton c5" data-options="plain:true" style="height: 90%" onclick="javaScript:$('#pbbIndex_yuangong_table').edatagrid('destroyRow')"><i class="fa fa-trash fa-fw" aria-hidden="true"></i>删除</a>
        </div>
        <table id="pbbIndex_yuangong_table"></table>
    </div>
    <!--主管表格-->
    <div title="<span class='opal-txt_bold opal-txt_size opal-txt_color_1'><i class='fa fa-align-justify fa-fw fa-spin'></i> 主管</span>">
        <div id='pbbTableToolbarB'>
            <a class="easyui-linkbutton c1" data-options="plain:true" style="height: 90%" onclick="javaScript:$('#pbbIndex_zhuguan_table').edatagrid('saveRow')"><i class="fa fa-floppy-o fa-fw" aria-hidden="true"></i>保存</a>
            <a class="easyui-linkbutton" data-options="plain:true">|</a>
            <a class="easyui-linkbutton c6" data-options="plain:true" style="height: 90%" onclick="javaScript:$('#pbbIndex_zhuguan_table').edatagrid('addRow')"><i class="fa fa-plus-square fa-fw" aria-hidden="true"></i>新增</a>
            <a class="easyui-linkbutton" data-options="plain:true">|</a>
            <a class="easyui-linkbutton c5" data-options="plain:true" style="height: 90%" onclick="javaScript:$('#pbbIndex_zhuguan_table').edatagrid('destroyRow')"><i class="fa fa-trash fa-fw" aria-hidden="true"></i>删除</a>
        </div>
        <table id="pbbIndex_zhuguan_table"></table>
    </div>
        <span style=" display:block;width: 500px;margin: 50px auto;font-size: 30px;color: #a45b13">点击【主管】或【检验员】展示表格</span>
        <span style=" display:block;width: 300px;margin: 50px auto;"><img src="/image/weiqu.png"></span>
    </div>
    <!--提交-->
    <div id="pbbIndex_button" style="height: 6%;text-align: center;background-color: #CCE6FF;">
        <button class="opal-btn" onclick="pbbsubmitdata()" style="width: 100%;height: 100%;line-height: 100%">提交数据</button>
    </div>
    <script src="/js/jxAssess/pbb/pbbInit.js"></script>
    <script>
        //重新加载数据
        function loadPbbData(){
            //对象属性当前时间更新
            pbbTable.getData();
            pbbTable.init();
        }
        //加载已有的绩效数据
        function loadPbbData2(){
          var data =pbbTable.getData2();
          if (data.jyData.total==0){
              layer.msg("当月么有数据！")
          }else {
              pbbTable.init();
          }
        }

        $("#pbbIndexAccordion").accordion({
            height:document.getElementById("pbbIndex_div").clientHeight*0.88
        })

        //提交数据
        function pbbsubmitdata(){
            //获取检验员表中所有行
            var rowsJy = $('#pbbIndex_yuangong_table').datagrid('getRows');
            //获取检验员页尾行
            var footersJy= $('#pbbIndex_yuangong_table').datagrid('getFooterRows');
            //获取主管表中所有行
            var rowsZg = $('#pbbIndex_zhuguan_table').datagrid('getRows');
            //获取主管表页尾行
            var footersZg= $('#pbbIndex_zhuguan_table').datagrid('getFooterRows');
            //添加年月
            rowsJy.forEach(function (val) {
                val.assessType=1;
                val.assessYear=pbbTable.year;
                val.assessMonth=pbbTable.month;
            })
            rowsZg.forEach((v) =>{
                v.assessType=2;
                v.assessYear=pbbTable.year;
                v.assessMonth=pbbTable.month;
            })
            footersJy.forEach(function (v) {
                v.assessType=1;
                v.remarks=v.empCode
                v.totalMoney=v.resultMoney;
                v.assessYear=pbbTable.year;
                v.assessMonth=pbbTable.month;
            })
            footersZg.forEach((v) =>{
                v.assessType=2;
                v.remarks=v.empCode
                v.totalMoney=v.resultMoney;
                v.assessYear=pbbTable.year;
                v.assessMonth=pbbTable.month;
            })

            //拼接
            var submitData={};
            rowsZg.forEach(v=>{
                rowsJy.push(v)
            })
            footersZg.forEach(v=>{
                footersJy.push(v)
            })
            submitData.jxAssessPbbs=rowsJy;
            submitData.jxAssessPbbTotals=footersJy;
            var submitDatas = JSON.stringify(submitData);
            var resultMsg=commonAjax("post","/jx/pbb/submitData",submitDatas,"application/json;charset=utf-8");

            if (resultMsg.status==200){
                alert("提交成功！")
                // submitData={};
                // submitData.pbbZgData=;
                // submitData.pbbZgDataTotal=footersZg;
                // var resultMsg=commonAjax("post","/jx/pbb/submitData",submitDatas,"application/json;charset=utf-8");

            }

        }

        layui.use('laydate',function () {
            var laydate = layui.laydate;

            //年月选择器
            laydate.render({
                elem: '#pbbIndex_div_date',
                type: 'month',
                value: new Date(),
                theme:'molv',
                showBottom:false,
                ready: function (date) { //选择日期后就关掉日期控件的事件
                    $(".layui-laydate").on('click', 'ul li', function () {
                        $(".layui-laydate").remove();
                    });
                },
                change:function (value,date,endDate) { //
                    //往input输入框赋值
                    this.elem[0].value=value;  //为啥这样写自己看属性了。。
                    //赋值时间
                    pbbTable.setCurrentDate(new Date(date.year+'-'+date.month));
                }
            });

        })

    </script>
</div>